package com.lingshu.app.ui.mine;

import android.content.Intent;
import android.os.Bundle;

import androidx.lifecycle.ViewModelProvider;

import com.lingshu.app.R;
import com.lingshu.app.base.BaseFragment;
import com.lingshu.app.databinding.FragmentMineBinding;
import com.lingshu.app.ui.login.LoginActivity;

import dagger.hilt.android.AndroidEntryPoint;

/**
 * @author 于定金
 * @version 1.0
 * @Date 2024/1/3 14:15
 * @Description
 */
@AndroidEntryPoint
public class MineFragment extends BaseFragment<FragmentMineBinding, MineFragmentViewModel> {
    /**
     * 传递参数
     *
     * @param param1
     * @param param2
     * @return
     */
    public static MineFragment newInstance(String param1, String param2) {
        MineFragment fragment = new MineFragment();
        Bundle args = new Bundle();
        fragment.setArguments(args);
        return fragment;
    }

    /**
     * 获取当前页面的布局资源ID
     *
     * @return 布局资源ID
     */
    @Override
    protected int getLayoutResId() {
        return R.layout.fragment_mine;
    }

    /**
     * 初始化ViewModel
     */
    @Override
    protected void initViewModel() {
        viewModel = new ViewModelProvider(this).get(MineFragmentViewModel.class);
    }

    /**
     * 绑定ViewModel
     */
    @Override
    protected void bindViewModel() {
        dataBinding.setViewModel(viewModel);
    }

    /**
     * 初始化
     */
    @Override
    protected void init() {
        viewModel.initData();
        dataBinding.btnLogout.setOnClickListener(v -> {
            startActivity(new Intent(context, LoginActivity.class));
            getActivity().finish();
        });
    }
}